package com.zzy.controller;

import com.zzy.dto.RequesParams;
import com.zzy.sercice.aiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;

@Controller
@RequestMapping("/hello")
public class HelloController {

    @Autowired
    private aiService aiService;

    @RequestMapping("/question")
    @ResponseBody
    public HashMap question(@RequestBody RequesParams requesParams)
    {
        HashMap<String, String> result = new HashMap<>();
        try {
            result.put("result", aiService.handleQuestion(requesParams));
            result.put("code","200");
        } catch (Exception e) {
            result.put("code","500");
        }
        return result;
    }


}
